package com.baidu.bas.core.view;

import com.baidu.bas.core.query.Condition;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhenchuan.liu
 */
@Getter
@Setter
@Accessors(chain = true)
public class TableQueryVo implements Serializable {

    private static final int maxPageSize = 200;

    private Integer page = 0;

    private Integer size = 10;

    private String sort;

    private Object linkTreeVal;

    private List<Condition> condition;

    public TableQueryVo addCondition(Condition cond){
        if(condition==null){
            this.condition = new ArrayList<>();
        }
        this.condition.add(cond);
        return this;
    }

    private boolean dataExport = false;

    public Integer getPageSize() {
        if (this.isDataExport()) {
            size = 1000000;
        } else {
            if (size > maxPageSize) {
                size = maxPageSize;
            }
        }
        return size;
    }

}
